package com.lzy.cloud.common.service.Impl;

import com.lzy.cloud.common.dtos.ParameterDto;
import com.lzy.cloud.common.entity.Parameter;
import com.lzy.cloud.common.mapper.ParameterMapperExt;
import com.lzy.cloud.common.service.ParameterService;
import com.lzy.framework.core.utils.DozerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ParameterServiceImpl implements ParameterService {

    @Autowired
    private ParameterMapperExt parameterMapperExt;

    @Override
    public ParameterDto selectById(Long id) {
        return DozerUtils.map(parameterMapperExt.selectByPrimaryKey(id), ParameterDto.class);
    }

    @Override
    public Boolean insert(ParameterDto parameterDto) {
        return parameterMapperExt.insertSelective(DozerUtils.map(parameterDto, Parameter.class)) > 0;
    }

    @Override
    public Boolean update(ParameterDto parameterDto) {
        return parameterMapperExt.updateByPrimaryKeySelective(DozerUtils.map(parameterDto, Parameter.class)) > 0;
    }

    @Override
    public Boolean delete(Long id) {
        return parameterMapperExt.deleteByPrimaryKey(id) > 0;
    }

    @Override
    public List<ParameterDto> queryByCode(ParameterDto parameterDto) {
        return parameterMapperExt.queryByCode(parameterDto);
    }
}
